/*
 * @(#)XfuzzyStringDataType.java        1.0 2009/03/25
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

package xfuzzy.xfds;

import xfuzzy.lang.Universe;

/**
 * Clase que describe un atributo de un conjunto de datos
 * 
 * @author Francisco Jos� Moreno Velo
 *
 */
public class XfdsAttribute  {

	//----------------------------------------------------------------------------//
	//                            MIEMBROS PRIVADOS                               //
	//----------------------------------------------------------------------------//
	
	/**
	 * Nombre del atributo
	 */
	private String name;
	
	/**
	 * Tipo de dato del atributo
	 */
	private XfdsDataType type;
	
	/**
	 * Marca para indicar si el atributo es una entrada (true) o una salida (false)
	 */
	private boolean input;
	
	//----------------------------------------------------------------------------//
	//                                CONSTRUCTOR                                 //
	//----------------------------------------------------------------------------//

	/**
	 * Constructor
	 */
	public XfdsAttribute(String name, XfdsDataType type) {
		this.name = name;
		this.type = type;
		this.input = true;
	}
		
	//----------------------------------------------------------------------------//
	//                             M�TODOS P�BLICOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Obtiene el nombre del atributo
	 */
	public String toString() {
		return this.name;
	}
	
	/**
	 * Obtiene el nombre del atributo
	 */
	public String getName() {
		return this.name;
	}
	
	/**
	 * Obtiene el tipo de dato del atributo
	 * @return
	 */
	public XfdsDataType getType() {
		return this.type;
	}
	
	/**
	 * Indica si el atributo es de entrada (true) o de salida (false)
	 * @return
	 */
	public boolean isInput() {
		return this.input;
	}
	
	/**
	 * Asigna la condici�n de entrada o salida del atributo
	 * @param io
	 */
	public void setInput(boolean io) {
		this.input = io;
	}
	
	/**
	 * Obtiene el valor del atributo asociado a la cadena reconocida
	 * @param v
	 * @return
	 */
	public double getValue(String v) {
		return this.type.getValue(v);
	}
	
	/**
	 * Obtiene el valor del rango del atributo
	 * @return
	 */
	public double getRange() {
		return this.type.getRange();
	}
	
	/**
	 * Obtiene el universo de discurso del atributo
	 * @return
	 */
	public Universe getUniverse() {
		return this.type.getUniverse();
	}
	
	//----------------------------------------------------------------------------//
	//                             M�TODOS PRIVADOS                               //
	//----------------------------------------------------------------------------//


}
